#/*
# * ffmpeg封装视频
# *
# * Copyright (c) 2014-2017 吴开杰
# * 
# * File name: Android.mk
# * 
# * Licensed under the Apache License, Version 2.0 (the "License");
# * you may not use this file except in compliance with the License.
# *  You may obtain a copy of the License at
# * 
# *     http://www.apache.org/licenses/LICENSE-2.0
# * 
# *  Unless required by applicable law or agreed to in writing, software
# *  distributed under the License is distributed on an "AS IS" BASIS,
# *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# *  See the License for the specific language governing permissions and
# *  limitations under the License.
# * 
# * All files in the folder are under this Apache License, Version 2.0.
# * Files in the jni/record folder may have a different license, see the respective files.
#*/

######################################################################
# Make shared library libffmpeg-encode.so
######################################################################
LOCAL_PATH	:= $(call my-dir)
include $(CLEAR_VARS)

######################################################################
# Make shared library libffmpeg-encode.so
######################################################################
CFLAGS := -Werror

# LOCAL_CFLAGS := $(LOCAL_C_INCLUDES:%=-I%)
LOCAL_CFLAGS := -DANDROID_NDK
LOCAL_CFLAGS += -DLOG_NDEBUG
LOCAL_CFLAGS += -DACCESS_RAW_DESCRIPTORS
LOCAL_CFLAGS += -O3 -fstrict-aliasing -fprefetch-loop-arrays

# LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -ldl
LOCAL_LDLIBS := -llog
LOCAL_LDLIBS += -landroid

# LOCAL_SHARED_LIBRARIES += usb100 uvc

include $(CLEAR_VARS)
LOCAL_MODULE := avcodec
LOCAL_SRC_FILES := ./ffmpeg/libs/arm64-v8a/libavcodec.a
# 静态库在ffmpeg/libs/
# LOCAL_SRC_FILES := $(LOCAL_PATH)/ffmpeg/libs/arm64-v8a/libavcodec.a
# 静态库在jniLibs
# LOCAL_SRC_FILES := /../../../jniLibs/$(TARGET_ARCH_ABI)/libavcodec.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := avfilter
LOCAL_SRC_FILES := ./ffmpeg/libs/arm64-v8a/libavfilter.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := avformat
LOCAL_SRC_FILES := ./ffmpeg/libs/arm64-v8a/libavformat.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := avutil
LOCAL_SRC_FILES := ./ffmpeg/libs/arm64-v8a/libavutil.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := fdk-aac
LOCAL_SRC_FILES := ./ffmpeg/libs/arm64-v8a/libfdk-aac.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := swresample
LOCAL_SRC_FILES := ./ffmpeg/libs/arm64-v8a/libswresample.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := swscale
LOCAL_SRC_FILES := ./ffmpeg/libs/arm64-v8a/libswscale.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE = x264
LOCAL_SRC_FILES := ./ffmpeg/libs/arm64-v8a/libx264.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE    := ffmpeg-encode
LOCAL_SRC_FILES := \
    com_tungkong_encode_VideoRecorder.cpp \
    VideoRecorder.cpp

LOCAL_C_INCLUDES        := $(LOCAL_PATH)/ffmpeg/include
LOCAL_STATIC_LIBRARIES  := avcodec avfilter avformat avutil fdk-aac swresample swscale x264
LOCAL_CPPFLAGS:=-std=c++11
LOCAL_LDLIBS := -llog

include $(BUILD_SHARED_LIBRARY)
